package com.google.code.nexttraffic.web.action;

import java.util.List;

import com.google.code.nexttraffic.service.impl.TerminalServiceImpl;
import com.google.code.nexttraffic.web.model.Terminal;

public class TerminalAction {

	private TerminalServiceImpl service = TerminalServiceImpl.getInstance();
	private Terminal terminal;
	private String terminalName = "";
	private String address = "";
	private String tel = "";
	private String scale = "";
	private String comments = "";
	private String timetableId = "";
	private String timetable = "";
	private List<Terminal> terminalList = null;

	public String execute() throws Exception {

		Terminal terminal = new Terminal();
		terminal.setTerminalName(getTerminalName());
		terminal.setAddress(getAddress());
		terminal.setTel(getTel());
		terminal.setScale(getScale());
		terminal.setComments(getComments());
		service.insertTerminal(terminal);

		return "success";
	}

	public String getListTerminal() throws Exception {

		setTerminalList(service.getListTerminal());

		return "success";
	}
	public String getTerminalDetailInfo() throws Exception {

		String terminalname=getTerminalName();
		System.out.println(terminalname);
		Terminal t = service.getTerminalDetailInfo(terminalname); 
		setTerminal(t);
		return "success";
	}
	public String getTimetableView() throws Exception {

		String aa=service.getTimeTable(timetableId);
		
		setTimetable(aa);
		
		return "success";
	}

	public String getTimetable() {
		return timetable;
	}

	public String getTerminalName() {
		return terminalName;
	}

	public void setTerminalName(String terminalName) {
		this.terminalName = terminalName;
	}

	public TerminalServiceImpl getService() {
		return service;
	}

	public void setService(TerminalServiceImpl service) {
		this.service = service;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getScale() {
		return scale;
	}

	public void setScale(String scale) {
		this.scale = scale;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public List<Terminal> getTerminalList() {
		return terminalList;
	}

	public void setTerminalList(List<Terminal> terminalList) {
		this.terminalList = terminalList;
	}

	public Terminal getTerminal() {
		return terminal;
	}

	public void setTerminal(Terminal terminal) {
		this.terminal = terminal;
	}

	public String getTimetableId() {
		return timetableId;
	}

	public void setTimetableId(String timetableId) {
		this.timetableId = timetableId;
	}

	public void setTimetable(String timetable) {
		this.timetable = timetable;
	}



}
